package com.testfileupload.uploadimg.design.intermediary.normal;

import java.util.Random;

public class Sale {
    public void sellIBMComputer(int num) {
        //访问库存
        Stock stock = new Stock();
        //访问采购
        Purcchase purcchase = new Purcchase();
        if (stock.getComputerNum() < num) {
            purcchase.buyIBMComputer(num);
        }
        System.out.println("销售电脑" + num + "台");
        stock.increase(num);
    }

    //0没人买，100卖的好
    public int getSaleStatus() {
        Random random = new Random();
        int saleStatus = random.nextInt(100);
        System.out.println("电脑销售的情况为" + saleStatus);
        return saleStatus;

    }

    public void offSale() {
        Stock stock = new Stock();
        //库房有多少卖多少
        System.out.println(
                "折价销售电脑" + stock.getComputerNum() + "台"
        );
    }
}
